//package com.zny.sescore.shiro;
//
//import org.apache.shiro.mgt.SecurityManager;
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
//import org.crazycake.shiro.RedisCacheManager;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.Filter;
//import java.util.LinkedHashMap;
//import java.util.Map;
//
///**
// * Shiro配置
// *
// * @author zhangnayi
// * @date 2021-03-30 23:10
// */
//@Configuration
//@ConditionalOnProperty(prefix = "global-setting", name = "shiro-enabled", havingValue = "true")
//public class ShiroConfig extends AbstractShiroConfig {
//
//    @Autowired
//    private ShiroCredentialsMatcher shiroCredentialsMatcher;
//
//    @Bean
//    public ShiroRealm getShiroRealm() {
//        ShiroRealm shiroRealm = new ShiroRealm();
//        shiroRealm.setCredentialsMatcher(shiroCredentialsMatcher);
//        return shiroRealm;
//    }
//
//    @Bean
//    public SecurityManager securityManager(DefaultWebSessionManager sessionManager, RedisCacheManager redisManager) {
//        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//        securityManager.setRealm(getShiroRealm());
//        securityManager.setSessionManager(sessionManager);
//        securityManager.setCacheManager(redisManager);
//        return securityManager;
//    }
//
//    @Bean
//    public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
//        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
//        shiroFilterFactoryBean.setSecurityManager(securityManager);
//        Map<String, String> map = new LinkedHashMap<>();
//        // 路径拦截配置
//        map.put("/system/account/login", "anon");
//        map.put("/system/account/register", "anon");
//        map.put("/system/account/forget_pwd", "anon");
//        map.put("/system/kaptcha/default", "anon");
//        map.put("/system/setting/**", "anon");
//        map.put("/department/list", "anon");
//        map.put("/hospital/list", "anon");
//        map.put("/message/send", "anon");
//        // - 放行swagger
//        map.put("/doc.html", "anon");
//        map.put("/webjars/**", "anon");
//        map.put("/swagger-resources/**", "anon");
//        map.put("/v2/api-docs/**", "anon");
//        map.put("/druid/**", "anon");
//        map.put("/sk", "anon");
//        map.put("/diseaseAssess/get", "anon");
//        map.put("/diseaseAssess/getByToken", "anon");
//        map.put("/diseaseAssess/getLastedDataByToken", "anon");
//        map.put("/diseaseAssess/assessByToken", "anon");
//        map.put("/risk/patient/getInfoByToken", "anon");
//        map.put("/risk/patient/getRiskLaboratoryValueByToken", "anon");
//        map.put("/equipment/ehr/**", "anon");
//        map.put("/hisData/getData", "anon");
//        map.put("/scheduled/**", "anon");
//        // - 放行社区医院ip查询接口
//        map.put("/hospitalIp/getIp", "anon");
//        map.put("/common/currentTimeMillis", "anon");
//        map.put("//Satisfaction/submitSatisfaction", "anon");
//        map.put("/**", "authc");
//
//
//        shiroFilterFactoryBean.setFilterChainDefinitionMap(map);
//        // 添加认证过滤器
//        Map<String, Filter> filters = new LinkedHashMap<>();
//        filters.put("authc", new ShiroAuthFilter());
//        shiroFilterFactoryBean.setFilters(filters);
//        return shiroFilterFactoryBean;
//    }
//}
